import { axiosGet, axiosPost, axiosPut, axiosDelete } from '/@/api/RequestBase';
import { BaseKeywordPageInput, SqlSugarPagedList, BaseIdInput } from '/@/api/BaseDto';

import { BasPrint, BasPrintAddInput, BasPrintUpdateInput, BasPrintGetDataAndTemplateInput, BasPrintGetDataAndTemplateOutput, BasPrintDraft, BasPrintDraftQueryInput } from './dto';

const service = 'BasPrint/'; // 要写后面的斜杠, 不要写前面的斜杠

export function BasPrintApi() {
	return {
		page: (data?: BaseKeywordPageInput) => {
			return axiosPost(service + 'page', data) as Promise<SqlSugarPagedList<BasPrint>>;
		},
		get: (id: number) => {
			return axiosGet(service + `get/${id}`) as Promise<BasPrint>;
		},
		add: (data?: BasPrintAddInput) => {
			return axiosPost(service + 'add', data) as Promise<number>;
		},
		updateCode: (data?: BasPrintUpdateInput) => {
			return axiosPut(service + 'updateCode', data) as Promise<boolean>;
		},
		delete: (id: number) => {
			return axiosDelete(service + `delete/${id}`) as Promise<boolean>;
		},
		queryDataAndTemplate: (data?: BasPrintGetDataAndTemplateInput) => {
			return axiosPost(service + 'queryDataAndTemplate', data) as Promise<BasPrintGetDataAndTemplateOutput>;
		},

		getDraft: (id: number) => {
			return axiosGet(service + `getDraft/${id}`) as Promise<BasPrintDraft>;
		},
		updateDraft: (data?: BasPrintDraft) => {
			return axiosPut(service + 'updateDraft', data) as Promise<boolean>;
		},
		queryDataAndTemplateForDraft: (data?: BasPrintDraftQueryInput) => {
			return axiosPost(service + 'queryDataAndTemplateForDraft', data) as Promise<BasPrintGetDataAndTemplateOutput>;
		},
		confirmDraft: (data: BaseIdInput) => {
			return axiosPost(service + `confirmDraft`, data) as Promise<boolean>;
		},
	};
}
